﻿using System;
using System.IO;
using System.Reflection;
using System.Threading;

using RaisingStudio.SmallProgram.Library.Internal;

namespace RaisingStudio.SmallProgram.Library
{
    [SmallProgramType]
    public static class Program
    {
#if XBOX
        private static string[] args = new string[0];
#else
        private static string[] args = Environment.GetCommandLineArgs();
#endif

        public static void Delay(Primitive milliSeconds)
        {
            Thread.Sleep(TimeSpan.FromMilliseconds((double)milliSeconds));
        }

        public static void End()
        {
            SmallProgramApplication.End();
        }

        public static Primitive GetArgument(Primitive index)
        {
            int num = (int)index;
            if ((num >= 1) && (num < args.Length))
            {
                return new Primitive(args[num]);
            }
            return new Primitive("");
        }

        public static Primitive ArgumentCount
        {
            get
            {
                return ((args.Length == 0) ? 0 : (args.Length - 1));
            }
        }

        public static Primitive Directory
        {
            get
            {
#if XBOX
                // TODO:
                return null;
#else
                return Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
#endif
            }
        }
    }
}

